﻿using System;
using System.Text;
using JetBrains.Annotations;
using Orchard.ContentManagement;
using Orchard.Data;
using Orchard.ContentManagement.Handlers;
using Orchard.Localization;
using Orchard.Logging;
using Orchard.Security;
using Whatsnexx.Models;

namespace Whatsnexx.Handlers
{
    [UsedImplicitly]
    public class WhatsnexxSettingsHandler : ContentHandler
    {
        private readonly IEncryptionService _encryptionService;


        public WhatsnexxSettingsHandler(IRepository<WhatsnexxSettingsPartRecord> repository, IEncryptionService encryptionService)
        {
            T = NullLocalizer.Instance;
            Logger = NullLogger.Instance;

            _encryptionService = encryptionService;
            Filters.Add(new ActivatingFilter<WhatsnexxSettingsPart>("Site"));
            Filters.Add(StorageFilter.For(repository));
        }

        public new ILogger Logger { get; set; }


       
        public Localizer T { get; set; }

        protected override void GetItemMetadata(GetContentItemMetadataContext context)
        {
            if (context.ContentItem.ContentType != "Site")
                return;
            base.GetItemMetadata(context);
            context.Metadata.EditorGroupInfo.Add(new GroupInfo(T("Whatsnexx")));
        }
    }
}